package com.example.leetdemo.plan1;

import java.util.ArrayDeque;
import java.util.Queue;

public class Sword042 {

    public static class RecentCounter {
        Queue<Integer> queue;

        public RecentCounter() {
            queue = new ArrayDeque<>();
        }

        public int ping(int t) {
            while (queue.size() > 0) {
                if (t - queue.peek() > 3000) {
                    queue.poll();
                } else {
                    break;
                }
            }
            queue.offer(t);
            return queue.size();
        }
    }
}
